// Fps Counter
// (c) jimon game studio

#ifndef JEH_CFPSCOUNTER
#define JEH_CFPSCOUNTER

#include "IFpsCounter.h"
#include "jeThreads.h"

namespace je
{
	namespace core
	{
		//! Fps Counter
		class CFpsCounter:public je::core::IFpsCounter
		{
		private:
			FpsCounterUpdateMode WorkMode;
			f32 DeltaTime;
			f32 InvDeltaTime;
			f32 Fps;

			u32 LoopCounts;
			f64 LastLoopTime;
			f64 TempLastLoopTime;
			f64 TempFps;

			u1 ResetCounter;
			u1 FpsUpdated;

			f64 FrameDT;
			DeltaTimeCorrectionMode DTMode;
			f32 DefaultDTFps;
			u32 DTMorphLevel;
			f64 LastDTTime;
			u1 ResetDT;

			u1 EnableDT;

			//! Update DeltaTime
			void UpdateDT();

		public:
			//! Constructor
			CFpsCounter();

			//! Destructor
			~CFpsCounter();

			//! Return Current Fps
			f32 GetFps();

			//! Return true if fps updated
			u1 IsUpdated();

			//! Set Update Mode
			void SetUpdateMode(FpsCounterUpdateMode Mode,f32 NewDeltaTime);

			//! Get Delta Time
			f64 GetDT();

			//! Set Delta Time Correction Mode
			void SetDTCorrectionMode(DeltaTimeCorrectionMode Mode,u32 NewMorphLevel);

			//! Set Delta Time Default FPS
			void SetDTDefaultFps(f32 Fps);

			//! If false - disable dt, getdt will return 1.0
			void SetDTEnable(u1 Enable);

			//! Loop Tick
			void LoopTick();
		};
	}
}

#endif
